package com.majx.service.impl;

import com.majx.mapper.UserMapper;
import com.majx.pojo.User;
import com.majx.service.Exception.UserExpetion;
import com.majx.service.UserService;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserServiceImpl implements UserService {

    private UserMapper userMapper;

    public void setUserMapper(UserMapper userMapper) {
        this.userMapper = userMapper;
    }

    /**
     * 验证登录
     * @param loginUser
     * @return
     */
    public User login(User loginUser) throws UserExpetion {
        User user = userMapper.login(loginUser);
        if(user == null){
            throw new UserExpetion("用户名密码错误或权限不够");
        }

        return user;
    }


    public List<User> queryUserPage(Integer page) {
        return null;
    }

    public Integer updateUser(User user) {
        return userMapper.updateUser(user);
    }

    public User getUser(Integer uid) {
        return userMapper.getUser(uid);
    }

    public Integer getUserCount() {
        return userMapper.getUserCount();
    }
}
